package com.lgy.service;

import org.camunda.bpm.engine.RepositoryService;
import org.camunda.bpm.engine.repository.Deployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.InputStream;

@Service
public class DeploymentServiceImpl implements IDeploymentService {
    @Autowired
    private RepositoryService repositoryService;

    public Deployment deployment(String resourceName, InputStream inputStream) {
        // 创建流程定义信息
        Deployment deployment = repositoryService.createDeployment()
                                .addInputStream(resourceName +".bpmn", inputStream)
                                .deploy();
        return deployment;
    }

    @Override
    public void deleteProcessDefinition(String processDefinitionId) {
        repositoryService.deleteProcessDefinition(processDefinitionId);
    }
}
